<!DOCTYPE html>
<html lang="en">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta charset="utf-8" />
		<title>首页 - 驴妈妈流立方</title>
		<meta name="description" content="overview &amp; stats" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
		<script src="${rc.contextPath}/assets/js/jquery.2.1.1.min.js"></script>
		<script src="${rc.contextPath}/assets/js/bootstrap.min.js"></script>
		<script src="${rc.contextPath}/assets/js/jquery-ui.custom.min.js"></script>
		<script src="${rc.contextPath}/assets/js/jquery.ui.touch-punch.min.js"></script>
		<script src="${rc.contextPath}/assets/js/bootbox.min.js"></script>
		<script src="${rc.contextPath}/assets/js/jquery.gritter.min.js"></script>
		<script src="${rc.contextPath}/assets/js/spin.min.js"></script>
		<!-- ace scripts -->
		<script src="${rc.contextPath}/assets/js/ace-elements.min.js"></script>
		<script src="${rc.contextPath}/assets/js/ace.min.js"></script>
		<!-- validator scripts -->
		<script src="${rc.contextPath}/assets/js/bootstrapValidator.min.js"></script>
		<!-- user scripts -->
		<script src="${rc.contextPath}/assets/js/user/base.js"></script>
		<link rel="stylesheet" href="${rc.contextPath}/assets/css/bootstrap.min.css" />
		<link rel="stylesheet" href="${rc.contextPath}/assets/font-awesome/4.2.0/css/font-awesome.min.css" />
		<!-- page specific plugin styles -->
		<link rel="stylesheet" href="${rc.contextPath}/assets/css/jquery-ui.custom.min.css" />
		<link rel="stylesheet" href="${rc.contextPath}/assets/css/jquery.gritter.min.css" />
		<!-- text fonts -->
		<link rel="stylesheet" href="${rc.contextPath}/assets/fonts/fonts.googleapis.com.css" />
		<!-- BootstrapValidator -->
		<link rel="stylesheet" href="${rc.contextPath}/assets/css/bootstrapValidator.min.css" />
		<!-- ace styles -->
		<link rel="stylesheet" href="${rc.contextPath}/assets/css/ace.min.css" class="ace-main-stylesheet" id="main-ace-style" />
		<!-- ace settings handler -->
		<script src="${rc.contextPath}/assets/js/ace-extra.min.js"></script>
		<link rel="stylesheet" href="${rc.contextPath}/assets/css/bsie-paginator.css" />

	</head>

	<body class="no-skin" style="background-color: #FFF;">
		<div class="page-content">
			<div class="row">
				<div class="col-xs-12">
					<div class="widget-box">
						<div class="widget-body" style="background-color: #EFF3F8;">
							<div class="widget-main">
								<form class="form-inline" id="searchForm" method="post" action="${rc.contextPath}/performanceStatistics/multidimensionalQueryCurve">
									<input id="chooseTimeVO" type="hidden" name="chooseTimeVO" value="${monitorVO.chooseTimeVO}">
									<div class="form-group">
										<label for="exampleInputName2">选择时段</label> 
										<input type="text" id="config-demo" name="config-demo" class="form-control time" value="${monitorVO.chooseTimeVO}">
											<button id="app_search" type="button"  onclick="replaceDate('1');" class="btn btn-white btn-sm">
												<span class="ace-icon icon-on-right bigger-110"></span>
												过去一周
											</button>
											<button id="app_search" type="button"  onclick="replaceDate('2');" class="btn btn-white btn-sm">
												<span class="ace-icon icon-on-right bigger-110"></span>
												过去两周
											</button>
									</div>
									<div class="form-group">
									  	<button id="search" type="button" onclick="searchClick();" class="btn btn-pink btn-sm">
											<span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
											Search
										</button>
									</div>
								</form>
							</div>
						</div>
					</div>
				</div>
			</div>
			
		   <div class="row">
				<div class="col-xs-12">
					<div class="widget-box">
						<div class="widget-header widget-header-small">
							<div class="row">
								<div class="col-xs-12">
									<div id="operator" style="width: 100%; height: 600px;"></div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div> 
			
		    <div class="row">
				<div class="col-xs-12">
					<div class="widget-box">
						<div class="widget-header widget-header-small">
							<div class="row">
								<div class="col-xs-12">
									<div id="networkType" style="width: 100%; height: 600px;"></div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div> 
			
		   <div class="row">
				<div class="col-xs-12">
					<div class="widget-box">
						<div class="widget-header widget-header-small">
							<div class="row">
								<div class="col-xs-12">
									<div id="region" style="width: 100%; height: 600px;"></div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			
		</div>

		<script src="${rc.contextPath}/assets/js/moment.min.js"></script>
		<script src="${rc.contextPath}/assets/js/bootstrap-datetimepicker.min.js"></script>
		
		<!-- <link rel="stylesheet" href="${rc.contextPath}/stylesheets/bootstrap.min.css"> -->
		<!-- <link rel="stylesheet" href="${rc.contextPath}/stylesheets/bootstrap-theme.min.css"> -->
		<link rel="stylesheet" href="${rc.contextPath}/stylesheets/daterangepicker.css">
		<script type="text/javascript" src="${rc.contextPath}/javascripts/jquery.2.1.1.min.js"></script>
	   	<script type="text/javascript" src="${rc.contextPath}/javascripts/bootstrap.min.js"></script>
	   	<script type="text/javascript" src="${rc.contextPath}/javascripts/moment.js"></script>
	   	<script type="text/javascript" src="${rc.contextPath}/javascripts/daterangepicker.js"></script>
	   	
	   	<script type="text/javascript" src="${rc.contextPath}/javascripts/echarts.js"></script>
	   	<script type="text/javascript" src="${rc.contextPath}/javascripts/china.js"></script>
	   	<script src="${rc.contextPath}/assets/js/jquery.gritter.min.js"></script>
		<script type="text/javascript">
		function replaceDate(obj){
    		if(obj == '1'){
    			startDate = new Date(new Date().getTime()-7*1000*60*60*24);
	    		endDate = new Date(new Date().getTime()-1*1000*60*60*24);
    		}else if(obj == '2'){
    			startDate = new Date(new Date().getTime()-14*1000*60*60*24);
	    		endDate = new Date(new Date().getTime()-1*1000*60*60*24);
    		}
		 	var dateStr = dateFormat(startDate) + " - " + dateFormat(endDate);
		    $("#chooseTimeVO").val(dateStr);
		    $(".time").val(dateStr);
    	}
		
			function dateFormat(date){
	    		var month = date.getMonth() + 1;
    		    var strDate = date.getDate();
    		    if (month >= 1 && month <= 9) {
    		        month = "0" + month;
    		    }
    		    if (strDate >= 0 && strDate <= 9) {
    		        strDate = "0" + strDate;
    		    }
    		    var currentdate = month + "/" + strDate + "/" + date.getFullYear();
    		    return currentdate;
	    	}

			function searchClick() {
				var chooseTime = $("#config-demo").val();
				$('#chooseTimeVO').val(chooseTime);
				$("#searchForm").submit();
			}
			
		
			jQuery(function($) {
				$('.time').daterangepicker(
						{
							startDate: new Date(new Date().getTime()-1*1000*60*60*24),
						    endDate: new Date(new Date().getTime()-1*1000*60*60*24),
							showDropdowns : true,
							showWeekNumbers : false,
							timePicker : false,
							timePicker12Hour : false,
							ranges : {
								'昨日': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
				            	'过去7天': [moment().subtract(7, 'days'), moment().subtract(1, 'days')],  
				                '过去31天': [moment().subtract(31, 'days'), moment().subtract(1, 'days')]
							},
							opens : 'right',
							buttonClasses : [ 'btn btn-default' ],
							applyClass : 'btn-small btn-pink blue',
							cancelClass : 'btn-small',
							format : 'yyyy-MM-dd',
							separator : ' to ',
							locale : {
								applyLabel : '确定',
								cancelLabel : '取消',
								fromLabel : '起始时间',
								toLabel : '结束时间',
								customRangeLabel : '自定义',
								daysOfWeek : [ '日', '一', '二', '三', '四', '五',
										'六' ],
								monthNames : [ '一月', '二月', '三月', '四月', '五月',
										'六月', '七月', '八月', '九月', '十月', '十一月',
										'十二月' ],
								firstDay : 1
							}
						},
						function(start, end, label) {//格式化日期显示框  

							$('.time').html(
									start.format('yyyy-MM-dd') + ' - '
											+ end.format('yyyy-MM-dd'));
						});
				
				var chooseTimeVO = "${monitorVO.chooseTimeVO}";
				if(chooseTimeVO != ""){
					$('#config-demo').val(chooseTimeVO);
				}


		 		option1 = {
	   			    title: {
	   			        text: '运营商调用接口内部耗时'
	   			    },
	   			    tooltip: {
	   			        trigger: 'axis'
	   			    },
	   			    legend: {
	   			        data:['中国移动','中国联通','中国电信','其它']
	   			    },
	   			    toolbox: {
	   			        show: true,
	   			        feature: {
	   			            dataView : {show: true, readOnly: false},
		  		            magicType : {show: true, type: ['line', 'bar']},
	   			            restore : {show: true},
		  		            saveAsImage : {show: true}
	   			        }
	   			    },
	   			 	dataZoom: [
	   			         {
	   			             show: true,
	   			             start: 0,
	   			             end: 100,
	   			         },
	   			     ],
	   			   calculable : true,
	   			   xAxis : [
	   	  		        {
	   	  		            type : 'category',
	   	  		            date: []
	   	  		        }
	   	  		    ],
	   	  		   yAxis : [
	  	  		        {
	  	  		        	type: 'value',
		   			        axisLabel: {
		   			            formatter: '{value} ms'
		   			        }
	  	  		        }
	  	  		    ],
	   			    series: [
	   			        {
	   			            name:'中国移动',
	   			            type:'line',
	   			            data:[],
	   			        },
	   			        {
	   			            name:'中国联通',
	   			            type:'line',
	   			            data:[],
	   			        },
	   			        {
	   			            name:'中国电信',
	   			            type:'line',
	   			            data:[],
	   			        },
	   			        {
	   			            name:'其它',
	   			            type:'line',
	   			            data:[],
	   			        }
	   			    ]
	   			};
		 		
		 		
		 		option2 = {
		   			    title: {
		   			        text: '不同网络调用接口内部耗时'
		   			    },
		   			    tooltip: {
		   			        trigger: 'axis'
		   			    },
		   			    legend: {
		   			        data:['2G', '3G', '4G', 'wifi', '其它']
		   			    },
		   			    toolbox: {
		   			        show: true,
		   			        feature: {
		   			        	/* 
	   			                //区域放大，缩小
	   			                dataZoom: {
	   			                yAxisIndex: 'none'
	   			            }, */  
	   			            dataView : {show: true, readOnly: false},
		  		            magicType : {show: true, type: ['line', 'bar']},
	   			            restore : {show: true},
		  		            saveAsImage : {show: true}
		   			        }
		   			    },
		   			 	dataZoom: [
		   			         {
		   			             show: true,
		   			             start: 0,
		   			             end: 100,
		   			         },
		   			     ],
		   			 calculable : true,
		   			 xAxis : [
		  	  		        {
		  	  		            type : 'category',
		  	  		            date: []
		  	  		        }
		  	  		    ],
			   	     yAxis : [
			  	  		        {
			  	  		        	type: 'value',
				   			        axisLabel: {
				   			            formatter: '{value} ms'
				   			        }
			  	  		        }
			  	  		    ],
		   			    series: [
		   			        {
		   			            name:'2G',
		   			            type:'line',
		   			            data:[],

		   			        },
		   			        {
		   			            name:'3G',
		   			            type:'line',
		   			            data:[],
		   			        },
		   			        {
		   			            name:'4G',
		   			            type:'line',
		   			            data:[],

		   			        },
		   			        {
		   			            name:'wifi',
		   			            type:'line',
		   			            data:[],
		   			        },
		   			        {
		   			            name:'其它',
		   			            type:'line',
		   			            data:[],

		   			        }
		   			    ]
		   			};
		 		
		 		
		 		
				option3 = {
		   			    title: {
		   			        text: '不同地区调用接口耗时(TOP10)'
		   			    },
		   			    tooltip: {
		   			        trigger: 'axis'
		   			    },
		   			    legend: {
		   			        data:['北京','上海','广州','浙江','江苏']
		   			    },
		   			    toolbox: {
		   			        show: true,
		   			        feature: {
		   			           /* 
		   			                //区域放大，缩小
		   			                dataZoom: {
		   			                yAxisIndex: 'none'
		   			            }, */  
		   			            dataView: {readOnly: true},
		   			            magicType: {type: ['line', 'bar']},
		   			            restore: {},
		   			            saveAsImage: {}
		   			        }
		   			    },
		   			 	dataZoom: [
		   			         {
		   			             show: true,
		   			             start: 0,
		   			             end: 100,
		   			         },
		   			     ],
		   			 alculable : true,
		   			 xAxis : [
		  	  		        {
		  	  		            type : 'category',
		  	  		            date: []
		  	  		        }
		  	  		    ],
			   	     yAxis : [
			  	  		        {
			  	  		        	type: 'value',
				   			        axisLabel: {
				   			            formatter: '{value} ms'
				   			        }
			  	  		        }
			  	  		    ],
		   			    series: [
		   			        {
		   			            name:'北京',
		   			            type:'line',
		   			            data:[],

		   			        },
		   			        {
		   			            name:'上海',
		   			            type:'line',
		   			            data:[],
		   			        },
		   			        {
		   			            name:'广州',
		   			            type:'line',
		   			            data:[],

		   			        },
		   			        {
		   			            name:'浙江',
		   			            type:'line',
		   			            data:[],
		   			        },
		   			        {
		   			            name:'江苏',
		   			            type:'line',
		   			            data:[],

		   			        }
		   			    ]
		   			};
		 		
		 		
		 		 $.ajax({
		    		   url: "${rc.contextPath}/performanceStatistics/ajaxmultidimensionalQueryCurve",
		    		  dataType:"json",
		    		   type : "POST",
					   data : {
							chooseTimeVO : chooseTimeVO,
						},
		    		   success: function(data){
		    			   if(data!=null){
						  	  	var myChart1 = echarts.init(document.getElementById('operator'));
						  	 	var myChart2 = echarts.init(document.getElementById('networkType'));
						  	    var myChart3 = echarts.init(document.getElementById('region'));
						  	 	
								var xAxis = data.dateInterval;
								option1.xAxis[0].data = xAxis;
								option1.series[0].data=data.cmData;
								option1.series[1].data=data.cuData;
								option1.series[2].data=data.ctData;
								option1.series[3].data=data.noneData;
							 	myChart1.setOption(option1,true);
							 	option2.xAxis[0].data = xAxis;
								option2.series[0].data=data.twoGData;
								option2.series[1].data=data.threeGData;
								option2.series[2].data=data.fourGData;
								option2.series[3].data=data.wifiData;
								option2.series[4].data=data.noneNetData;
							 	myChart2.setOption(option2,true);
						        option3.xAxis[0].data = xAxis;
						        option3.series=data.series;
								option3.legend.data=data.legend;
								myChart3.setOption(option3,true);
						  	 	
						  	    window.onresize = function(){
						  	  	  myChart1.resize();
						  	      myChart2.resize();
						  		  myChart3.resize();
						  	  } 
		    			   }
		    		   }
			   		}); 

			})
			
		</script>
		

		<link rel="stylesheet" href="${rc.contextPath}/assets/css/bootstrap.css" /> 
		<script src="${rc.contextPath}/assets/js/chosen.jquery.js"></script>
		
		<script>
			 $(function() {
		        $('.chosen-select').chosen();
		       	$('.chosen-select-deselect').chosen({ allow_single_deselect: true });
		     }); 
	      	
			 function statistics(){
				$('#statistics').show();
				$('.chosen-select').chosen("destroy").chosen();
		       	$('.chosen-select-deselect').chosen({ allow_single_deselect: true });
			 }
	    </script>
	    
	</body>
</html>